package com.ruoyi.sqlserver.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.sqlserver.domain.PesCompany;
import com.ruoyi.sqlserver.service.IPesCompanyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * pesController
 *
 * @author wkw
 * @date 2024-04-14
 */
@RestController
@RequestMapping("/pes/COMPANY")
public class PesCompanyController extends BaseController
{
    @Autowired
    private IPesCompanyService pesCompanyService;

    /**
     * 查询pes列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PesCompany pesCompany)
    {
        startPage();
        List<PesCompany> list = pesCompanyService.selectPesCompanyList(pesCompany);
        return getDataTable(list);
    }

    /**
     * 导出pes列表
     */
    @PreAuthorize("@ss.hasPermi('pes:COMPANY:export')")
    @Log(title = "pes", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PesCompany pesCompany)
    {
        List<PesCompany> list = pesCompanyService.selectPesCompanyList(pesCompany);
        ExcelUtil<PesCompany> util = new ExcelUtil<PesCompany>(PesCompany.class);
        util.exportExcel(response, list, "pes数据");
    }

    /**
     * 获取pes详细信息
     */
    @PreAuthorize("@ss.hasPermi('pes:COMPANY:query')")
    @GetMapping(value = "/{coId}")
    public AjaxResult getInfo(@PathVariable("coId") String coId)
    {
        return success(pesCompanyService.selectPesCompanyByCoId(coId));
    }

    /**
     * 新增pes
     */
    @PreAuthorize("@ss.hasPermi('pes:COMPANY:add')")
    @Log(title = "pes", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PesCompany pesCompany)
    {
        return toAjax(pesCompanyService.insertPesCompany(pesCompany));
    }

    /**
     * 修改pes
     */
    @PreAuthorize("@ss.hasPermi('pes:COMPANY:edit')")
    @Log(title = "pes", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PesCompany pesCompany)
    {
        return toAjax(pesCompanyService.updatePesCompany(pesCompany));
    }

    /**
     * 删除pes
     */
    @PreAuthorize("@ss.hasPermi('pes:COMPANY:remove')")
    @Log(title = "pes", businessType = BusinessType.DELETE)
    @DeleteMapping("/{coIds}")
    public AjaxResult remove(@PathVariable String[] coIds)
    {
        return toAjax(pesCompanyService.deletePesCompanyByCoIds(coIds));
    }
}
